package com.fetaphon.blelibrary.entity.data;

import com.fetaphon.blelibrary.utils.ByteUtils;

/**
 * 电芯特性
 */
public class DxParams {

    private int p1;//电芯特性 1byte 0:磷酸铁锂电池，1:钛酸锂电池，2：三元锂电池，3：其他
    private int p2;//额定容量 1byte 单位：AH
    private int p3;//串数 1byte
    private int p4;//循环次数 4byte

    public DxParams(byte[] bytes) {
        try {
            byte[] bytes1 = ByteUtils.subBytes(bytes, 0, 1);
            byte[] bytes2 = ByteUtils.subBytes(bytes, 1, 1);
            byte[] bytes3 = ByteUtils.subBytes(bytes, 2, 1);
            byte[] bytes4 = ByteUtils.subBytes(bytes, 3, 4);
            this.p1 = ByteUtils.byteToInt(bytes1);
            this.p2 = ByteUtils.byteToInt(bytes2);
            this.p3 = ByteUtils.byteToInt(bytes3);
            this.p4 = ByteUtils.byteToInt(bytes4);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public int getP1() {
        return p1;
    }

    public void setP1(int p1) {
        this.p1 = p1;
    }

    public int getP2() {
        return p2;
    }

    public void setP2(int p2) {
        this.p2 = p2;
    }

    public int getP3() {
        return p3;
    }

    public void setP3(int p3) {
        this.p3 = p3;
    }

    public int getP4() {
        return p4;
    }

    public void setP4(int p4) {
        this.p4 = p4;
    }

    @Override
    public String toString() {
        return "DxParams{" +
                "p1=" + p1 +
                ", p2=" + p2 +
                ", p3=" + p3 +
                ", p4=" + p4 +
                '}';
    }
}
